    Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As _
                 System.EventArgs) Handles btnCalc.Click
      Dim number As Long, BitCount As Integer

      If rbBits8.Checked = True Then    ' Wynik 8-bitowy?
        BitCount = 8
      Else
        If rbBits16.Checked = True Then ' A moe 16-bitowy?
          BitCount = 16
        Else
          BitCount = 32                 ' Chyba jednak 32-bitowy.
        End If
      End If
      If txtNumber.Text <> "" Then ' Czy zostaa wprowadzona liczba 
                                   '           dziesitna?
        number = CLng(txtNumber.Text)
        txtResult.Text = ConvertToBinary(number, BitCount) 
                ' przekszta na binarn        
      Else
        If txtResult.Text <> "" Then ' a moe jednak liczba binarna...
          txtNumber.Text = ConvertToDecimal(txtResult.Text) 
                    ' przekszta na dziesitn
        End If
      End If

    End Sub
